package cn.ligoo.dtu.web.springmvc;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.util.WebUtils;

import cn.ligoo.dtu.web.Constants;

@Controller
@RequestMapping("/themes")
public class ThemesController {

	private final Logger logger = LoggerFactory.getLogger(ThemesController.class);

	@RequestMapping(value = "/{themes}", produces = "text/html;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String save(HttpServletRequest request, @PathVariable String themes) {
		logger.debug("...themes:{}", themes);
		WebUtils.setSessionAttribute(request, Constants.SESSION_THEMES, themes);
		return String.format(Constants.JSON_SUCCESS, null, null);
	}
}
